<?php

/**
 * ACoreLogger
 *
 * @author Usenko Timur <usenko.timur@gmail.com>
 * @package logger
 */

CCore::Using('base.utils');

/**
 * @package logger
 */
abstract class ACoreLogger
{
	#<editor-fold defaultstate="collapsed" desc="abstract functions">
	/**
	 * @param string $sDesc
	 * @return bool
	 */
	abstract protected function writeImplementation($sDesc);

	/**
	 * @param string $sTimePrefix
	 * @param string $sErrorDesc
	 * @return string
	 */
	abstract protected function logLineImplementation($sTimePrefix, $sErrorDesc);

	/**
	 * @return bool
	 */
	abstract protected function clearImplementation();
	#</editor-fold>
	
	/**
	 * @final
	 * @param string $sDesc
	 * @param array $aSecretValues = array()
	 * @return bool
	 */
	final public function Write($sDesc, $aSecretValues = array())
	{
		CCore::CheckTypes(array('$sDesc', '$aSecretValues'));
		
		return $this->writeImplementation($this->logLineImplementation(
			CCoreBaseUtils::GetTimeWithMicroSec(),
				(0 < count($aSecretValues) ? str_replace($aSecretValues, '********', $sDesc) : $sDesc
			)));
	}

	/**
	 * @final
	 * @return bool
	 */
	final public function Clear()
	{
		return $this->clearImplementation();
	}
}
